package com.wx.tgp.socket.demo.thread;

import java.io.FileInputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;

/**
 * Created by Administrator on 2016/8/26.
 */
public class InterfaceCallbackDigest implements Runnable {

    private InterfaceCallbackDigestUserInterface callback;
    private String fileName;
    public InterfaceCallbackDigest(String fileName,InterfaceCallbackDigestUserInterface callback){
        this.callback = callback;
        this.fileName = fileName;
    }

    public void run(){
        try{
            FileInputStream fis = new FileInputStream(fileName);
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            DigestInputStream dis = new DigestInputStream(fis,md);
            while(dis.read()!=-1){
//                log.info(dis.read());
            };
            dis.close();
            byte[] digest = md.digest();
//            CallbackDigestUserInterface   CallbackDigestUserInterface
            callback.recevierCallback(digest);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
